package chapter10.innerclass.HomeWork;

/**
 * @Auther: Tx
 * @Date: 2022/5/3 16:08
 */
public class Homework02 {
    public static void main(String[] args) {
        Car car1 = new Car(50.0);
        Car.Air air1 = car1.new Air();
        air1.flow();

        Car car2 = new Car(10);
        Car.Air air2 = car2.getInstance();
        air2.flow();
    }
}
class Car{
    private double temperature;
    public class Air{
        void flow(){
            if (temperature>40){
                System.out.println("吹冷风");
            }
            else if(temperature<0){
                System.out.println("吹热风");
            }else{
                System.out.println("关闭空调");
            }
        }
    }
    public Car(double temperature) {
        this.temperature = temperature;
    }
//    提供一个方法返回air对象
       public Air getInstance() {
        return new Air() ;
    }
}